package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.ProductionOrder;
import com.qidianit.mes.pro.service.ProductionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: YanJiRan
 * @Date: 2025/9/20 - 下午2:17
 */
@RestController
@RequestMapping("/productionOrder")
public class ProductionOrderController {
    @Autowired
    private ProductionOrderService productionOrderService;

    @GetMapping("/page")
    public Result<PageInfo<ProductionOrder>> list(ProductionOrder productionOrder, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int pageSize){
        return productionOrderService.selectList(productionOrder,pageNum,pageSize);
    }

    @GetMapping("{id}")
    public Result<ProductionOrder> getByCode(@PathVariable("id") Long id){
        return productionOrderService.selectById(id);
    }

    @PostMapping("/add")
    public Result<ProductionOrder> save(@RequestBody ProductionOrder productionOrder){
        return productionOrderService.saveProductionOrder(productionOrder);
    }

    @PutMapping("/update")
    public Result<ProductionOrder> update(@RequestBody ProductionOrder productionOrder){
        return productionOrderService.updateById(productionOrder);
    }

    @DeleteMapping("/delete/{id}")
    public Result<ProductionOrder> deleteById(@PathVariable Long id){
        return productionOrderService.deleteById(id);
    }

}
